*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: TABLE G7 (Online Appendix)

***************************

cd ""

putexcel set "Tables/G7", modify 

global horizon 6 

************ PREPARE DATASET **********

run "Do files/Clean dataset"

* Alternative EOS
gen epsilon2 = (EOS_stock4_OLS-1)/EOS_stock4_OLS
gen epsilon3 = (EOS_serv4_noIRR-1)/EOS_serv4_noIRR
gen epsilon4 = (EOS_serv4_wTRENDS-1)/EOS_serv4_wTRENDS

* Create explanatory variables
forvalues v = 2 / 4 {
gen s2v`v' = layoff_rate
gen s3v`v' = -epsilon`v'
gen s4v`v' = -epsilon`v'*layoff_rate
forvalues i = 2 / 4 {
quietly sum s`i'v`v', detail
local sc1 = r(p75)
local sc2 = r(p25)
gen r`i'v`v' = (EPLregularworkers*s`i'v`v')/(`sc1'-`sc2')  
}

* Lags and forwards of explanatory variables
forvalues s = 2/4 {
forvalues l = 1 / 6 {
gen l`l'r`s'v`v' = l`l'.r`s'v`v'
}
forvalues f = 1 / 5 {
gen f`f'r`s'v`v' = f`f'.r`s'v`v'
}
}

* Global for forward variables (Teulings and Zubanov)
forvalues s = 2/4 {
global f1`s'v`v'
global f2`s'v`v' f1r`s'v`v'
global f3`s'v`v' f1r`s'v`v' f2r`s'v`v'
global f4`s'v`v' f1r`s'v`v' f2r`s'v`v' f3r`s'v`v'
global f5`s'v`v' f1r`s'v`v' f2r`s'v`v' f3r`s'v`v' f4r`s'v`v'
global f6`s'v`v' f1r`s'v`v' f2r`s'v`v' f3r`s'v`v' f4r`s'v`v' f5r`s'v`v'
}
}

forvalues v = 2 / 4 {
gen t2v`v' = EPLtemporaryworkers*layoff_rate*epsilon`v'
gen t3v`v' = EPLtemporaryworkers*layoff_rate*epsilon`v'
gen t4v`v' = EPLtemporaryworkers*layoff_rate*epsilon`v'
}

************ ANALYSIS **********

forvalues s = 2/4 {
mat mat`s' = J(12,$horizon,.)

* Baseline
forvalues i= 1/$horizon {
quietly reghdfe  Y`i' r`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[1,`i'] = results[1,1]
mat mat`s'[2,`i'] = results[2,1]
mat mat`s'[3,`i'] = results[4,1]
* stock
quietly reghdfe  Y`i' r`s'v2 l1Y l2Y l3Y l4Y l1r`s'v2 l2r`s'v2 l3r`s'v2 l4r`s'v2 t`s' ${f`i'`s'v2}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[4,`i'] = results[1,1]
mat mat`s'[5,`i'] = results[2,1]
mat mat`s'[6,`i'] = results[4,1]
* rental rate
quietly reghdfe  Y`i' r`s'v3 l1Y l2Y l3Y l4Y l1r`s'v3 l2r`s'v3 l3r`s'v3 l4r`s'v3 t`s' ${f`i'`s'v3}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[7,`i'] = results[1,1]
mat mat`s'[8,`i'] = results[2,1]
mat mat`s'[9,`i'] = results[4,1]
* technical change
quietly reghdfe  Y`i' r`s'v4 l1Y l2Y l3Y l4Y l1r`s'v4 l2r`s'v4 l3r`s'v4 l4r`s'v4 t`s' ${f`i'`s'v4}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[10,`i'] = results[1,1]
mat mat`s'[11,`i'] = results[2,1]
mat mat`s'[12,`i'] = results[4,1]
}
}

************ SAVE OUTPUT **********

putexcel B4=matrix(mat2)
putexcel B18=matrix(mat4)
